def method(nums):

    # 1 乘以自己下标，然后统计每个值的出现次数
    d = {}
    for i in range(len(nums)):
        t = nums[i] * (i + 1)
        if t not in d:
            d[t] = 0
        d[t] += 1
    # 2 计算匹配二元组的数量
    result = 0
    for n in d.values():
        result += n * (n - 1) // 2

    return result 

if __name__ == '__main__':
    _ = int(input())
    nums = [int(x) for x in input().split(' ')]
    result = method(nums)
    print(result)